package service.StrategyService._stub;

import VO.StrategyVO;
import service.StrategyService.WebsiteStrategyService;
import util.Message;
import util.UserType;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class WebsiteStrategyService_stub extends UnicastRemoteObject implements WebsiteStrategyService{

	private static final long serialVersionUID = 710123587653997368L;

	public WebsiteStrategyService_stub() throws RemoteException {
		super();
	}

	public  Iterator<StrategyVO> getStrategy()throws RemoteException {
		List<StrategyVO> list= new ArrayList<StrategyVO>();
		StrategyVO strategyVO=new StrategyVO("insomnia",UserType.CLIENT,"1元可住",30);
		list.add(strategyVO);
		Iterator<StrategyVO> iter=list.iterator();
		return  iter;
	 }

     public Message addNewStrategy(StrategyVO strategyVO)throws RemoteException {
	        StrategyVO newStrategyVO=strategyVO.getStrategyVO();
	       if (newStrategyVO.getContent()==null||newStrategyVO.getDiscount()<=0){
	            return Message.NOT_COMPLETE;
	        }else if(newStrategyVO.getUserType()==UserType.HOTELSTAFF||newStrategyVO.getUserType()==UserType.WEBSITEMARKERER){
	            return Message.SUCCESS;
	        }else{
	            return Message.FAIL;
	        }
	    }

	    public boolean removeStrategy(StrategyVO strategyVO)throws RemoteException {
	        if (strategyVO!=null){
	            return true;
	        }else{
	            return false;
	        }
	    }
}
